/*
 * point.c
 *
 *  Created on: Oct 13, 2011
 *      Author:
 */

#include "point.h"

point *pointAlloc(float x, float y, float Theta) {

	point *pointPtr = NULL;

	pointPtr = (point *)malloc(1 * sizeof(point));

	if (pointPtr == NULL) {
		free(pointPtr);
		pointPtr = NULL;
		return NULL;
	}else {
		pointPtr->x = x;
		pointPtr->y = y;
		if(Theta >= 0 && Theta<= 180)
			pointPtr->Theta = Theta*PI/180;
		else{
			Theta = 360.0-Theta;
			pointPtr->Theta = -(Theta*PI/180);
		}

		return pointPtr;
	}

}

point *pointAlloEmp() {

	point *pointPtr = NULL;

	pointPtr = (point *)malloc(1 * sizeof(point));

	if (pointPtr == NULL) {
		free(pointPtr);
		pointPtr = NULL;
		return NULL;
	}else {
		return pointPtr;
	}
}
